<template>
  <h3>路由</h3>
  <button @click="fn">跳转</button>
</template>

<script setup>
import { useRouter } from "vue-router";

// useRouter函数返回router实例，相当于this.$router
// useRouter也只能在js的顶层进行调用
const router = useRouter();

const fn = () => {
  // this.$router.push("/detail");

  // const router = useRouter(); ×
  router.push("/detail/777");
};
</script>
